﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Tag="Animation: Chris Cavanaugh Preloader Page">
    <Canvas>
        <!--
            For more, see “XAML Loading Animation”
            [http://chriscavanagh.wordpress.com/2008/02/11/xaml-loading-animation/]
            and, for WPF, “Improved WPF Loading Animation”
            [http://chriscavanagh.wordpress.com/2008/07/25/improved-xaml-loading-animation/]
        -->
        <Canvas.RenderTransform>
            <TransformGroup>

                <RotateTransform x:Name="angle" Angle="0" CenterX="0.5" CenterY="0.5"/>

                <!-- Ideally remove the translation and scale from here
                 and let the container apply them instead -->

                <TranslateTransform X="0" Y="0"/>
                <ScaleTransform ScaleX="100" ScaleY="100"/>

            </TransformGroup>
        </Canvas.RenderTransform>

        <Canvas.Triggers>
            <EventTrigger RoutedEvent="Canvas.Loaded">
                <BeginStoryboard>
                    <Storyboard x:Name="rotation">
                        <DoubleAnimation To="1" Duration="0:0:1"
                            Storyboard.TargetName="content"
                            Storyboard.TargetProperty="Opacity"/>
                        <DoubleAnimation From="0" To="359" Duration="0:0:1" RepeatBehavior="0:3:0"
                            Storyboard.TargetName="angle"
                            Storyboard.TargetProperty="Angle"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Canvas.Triggers>

        <Canvas Name="content" Opacity="0">

            <Path Width="1" Height="1" Stretch="Fill" Stroke="Green" StrokeThickness="0.1" StrokeStartLineCap="Round">
                <Path.Data>
                    <PathGeometry>
                        <PathFigure StartPoint="1,0">
                            <ArcSegment Point="0,-1" RotationAngle="90" SweepDirection="Clockwise" IsLargeArc="True" Size="1,1"/>
                        </PathFigure>
                    </PathGeometry>
                </Path.Data>
            </Path>

            <Path Canvas.Left="0.49" Canvas.Top="-0.05" Width="0.2" Height="0.2" Stretch="Fill" Fill="Green">
                <Path.Data>
                    <PathGeometry>
                        <PathFigure StartPoint="0,-1.1">
                            <LineSegment Point="0.1,-1" />
                            <LineSegment Point="0,-0.9" />
                        </PathFigure>
                    </PathGeometry>
                </Path.Data>
            </Path>

        </Canvas>
    </Canvas>
</UserControl>
